package com.af.system.api.result;

/**
 * @author : zhenyun.su
 * @comment : 定义结果结构
 * @since : 2020/7/7
 */

public class AfResult<T> {

    private Boolean status;

    private Integer code;

    private String msg;

    private T data;

    public AfResult() {
    }

    public AfResult(Integer code, String msg) {
        this(null, code, msg, null);
    }

    public AfResult(Boolean status, Integer code, String msg) {
        this(status, code,msg,null);
    }

    public AfResult(Boolean status, Integer code, String msg, T data) {
        this.status = status;
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public AfResult<T> status(Boolean value){
        this.setStatus(value);
        return this;
    }
    public AfResult<T> code(Integer value){
        this.setCode(value);
        return this;
    }

    public AfResult<T> msg(String value){
        this.setMsg(value);
        return this;
    }

    public AfResult<T> data(T value){
        this.setData(value);
        return this;
    }

    public Boolean getStatus() {
        return status;
    }

    public void setStatus(Boolean status) {
        this.status = status;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Result{" +
                "status=" + status +
                ", code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
